package com.rr.easy;

/**
 * @author zhuangcanrun
 * @Date 2021/12/12/22:11
 * @description
 **/

/*
* 转换成小写字母
* https://leetcode-cn.com/problems/to-lower-case/
* */
public class ToLowerCase {
    public String toLowerCase(String s) {
//        return s.toLowerCase();
        int length = s.length();
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < length; i++) {
            char c = s.charAt(i);
            if (c > 'A' && c < 'Z') {
                builder.append(c+=32);
//                按位或运算也可以得到小写
//                builder.append(c|=32);
            } else {
                builder.append(c);
            }
        }
        return builder.toString();
    }

    public static void main(String[] args) {
        ToLowerCase toLowerCase = new ToLowerCase();
        System.out.println(toLowerCase.toLowerCase("Hello"));
    }
}
